In [1]:
import pandas as pd
import plotly.express as px
import json

caminho_geo_json = r"C:\Dashboardcovid19\geojson\brasil_estados.json"
caminho_geo_json = caminho_geo_json.replace("\\", "/")

caminho_df = r"C:\Dashboardcovid19\Frames\estadosxdespesas.csv"
caminho_df = caminho_df.replace("\\", "/")

df = pd.read_csv(caminho_df, encoding="latin-1", delimiter=",")
geojson = json.load(open(caminho_geo_json))

fig = px.choropleth(df, geojson=geojson, locations='uf', color='valor', #color_continuous_scale='blues',
                    scope='south america', projection='natural earth', width=700, height=700, color_discrete_map={'color': 'red'},
                   template='plotly_dark')
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.update_layout(
    title={
        'text': "Espectro de volume de contratos por estado",
        'y':0.98,
        'x':0.5,
        'xanchor': 'center',
        'yanchor': 'top'})
fig.update_layout(activeshape_opacity=0)
fig.show()
C:\Users\Markos Alves\anaconda3copy\lib\site-packages\scipy\__init__.py:146: UserWarning: A NumPy version >=1.16.5 and <1.23.0 is required for this version of SciPy (detected version 1.23.3
  warnings.warn(f"A NumPy version >={np_minversion} and <{np_maxversion}"
In [2]:
print(help(px.choropleth))
Help on function choropleth in module plotly.express._chart_types:

choropleth(data_frame=None, lat=None, lon=None, locations=None, locationmode=None, geojson=None, featureidkey=None, color=None, facet_row=None, facet_col=None, facet_col_wrap=0, facet_row_spacing=None, facet_col_spacing=None, hover_name=None, hover_data=None, custom_data=None, animation_frame=None, animation_group=None, category_orders=None, labels=None, color_discrete_sequence=None, color_discrete_map=None, color_continuous_scale=None, range_color=None, color_continuous_midpoint=None, projection=None, scope=None, center=None, fitbounds=None, basemap_visible=None, title=None, template=None, width=None, height=None)
        In a choropleth map, each row of `data_frame` is represented by a
        colored region mark on a map.
        
    Parameters
    ----------
    data_frame: DataFrame or array-like or dict
        This argument needs to be passed for column names (and not keyword
        names) to be used. Array-like and dict are tranformed internally to a
        pandas DataFrame. Optional: if missing, a DataFrame gets constructed
        under the hood using the other arguments.
    lat: str or int or Series or array-like
        Either a name of a column in `data_frame`, or a pandas Series or
        array_like object. Values from this column or array_like are used to
        position marks according to latitude on a map.
    lon: str or int or Series or array-like
        Either a name of a column in `data_frame`, or a pandas Series or
        array_like object. Values from this column or array_like are used to
        position marks according to longitude on a map.
    locations: str or int or Series or array-like
        Either a name of a column in `data_frame`, or a pandas Series or
        array_like object. Values from this column or array_like are to be
        interpreted according to `locationmode` and mapped to
        longitude/latitude.
    locationmode: str
        One of 'ISO-3', 'USA-states', or 'country names' Determines the set of
        locations used to match entries in `locations` to regions on the map.
    geojson: GeoJSON-formatted dict
        Must contain a Polygon feature collection, with IDs, which are
        references from `locations`.
    featureidkey: str (default: `'id'`)
        Path to field in GeoJSON feature object with which to match the values
        passed in to `locations`.The most common alternative to the default is
        of the form `'properties.<key>`.
    color: str or int or Series or array-like
        Either a name of a column in `data_frame`, or a pandas Series or
        array_like object. Values from this column or array_like are used to
        assign color to marks.
    facet_row: str or int or Series or array-like
        Either a name of a column in `data_frame`, or a pandas Series or
        array_like object. Values from this column or array_like are used to
        assign marks to facetted subplots in the vertical direction.
    facet_col: str or int or Series or array-like
        Either a name of a column in `data_frame`, or a pandas Series or
        array_like object. Values from this column or array_like are used to
        assign marks to facetted subplots in the horizontal direction.
    facet_col_wrap: int
        Maximum number of facet columns. Wraps the column variable at this
        width, so that the column facets span multiple rows. Ignored if 0, and
        forced to 0 if `facet_row` or a `marginal` is set.
    facet_row_spacing: float between 0 and 1
        Spacing between facet rows, in paper units. Default is 0.03 or 0.0.7
        when facet_col_wrap is used.
    facet_col_spacing: float between 0 and 1
        Spacing between facet columns, in paper units Default is 0.02.
    hover_name: str or int or Series or array-like
        Either a name of a column in `data_frame`, or a pandas Series or
        array_like object. Values from this column or array_like appear in bold
        in the hover tooltip.
    hover_data: list of str or int, or Series or array-like, or dict
        Either a list of names of columns in `data_frame`, or pandas Series, or
        array_like objects or a dict with column names as keys, with values
        True (for default formatting) False (in order to remove this column
        from hover information), or a formatting string, for example ':.3f' or
        '|%a' or list-like data to appear in the hover tooltip or tuples with a
        bool or formatting string as first element, and list-like data to
        appear in hover as second element Values from these columns appear as
        extra data in the hover tooltip.
    custom_data: list of str or int, or Series or array-like
        Either names of columns in `data_frame`, or pandas Series, or
        array_like objects Values from these columns are extra data, to be used
        in widgets or Dash callbacks for example. This data is not user-visible
        but is included in events emitted by the figure (lasso selection etc.)
    animation_frame: str or int or Series or array-like
        Either a name of a column in `data_frame`, or a pandas Series or
        array_like object. Values from this column or array_like are used to
        assign marks to animation frames.
    animation_group: str or int or Series or array-like
        Either a name of a column in `data_frame`, or a pandas Series or
        array_like object. Values from this column or array_like are used to
        provide object-constancy across animation frames: rows with matching
        `animation_group`s will be treated as if they describe the same object
        in each frame.
    category_orders: dict with str keys and list of str values (default `{}`)
        By default, in Python 3.6+, the order of categorical values in axes,
        legends and facets depends on the order in which these values are first
        encountered in `data_frame` (and no order is guaranteed by default in
        Python below 3.6). This parameter is used to force a specific ordering
        of values per column. The keys of this dict should correspond to column
        names, and the values should be lists of strings corresponding to the
        specific display order desired.
    labels: dict with str keys and str values (default `{}`)
        By default, column names are used in the figure for axis titles, legend
        entries and hovers. This parameter allows this to be overridden. The
        keys of this dict should correspond to column names, and the values
        should correspond to the desired label to be displayed.
    color_discrete_sequence: list of str
        Strings should define valid CSS-colors. When `color` is set and the
        values in the corresponding column are not numeric, values in that
        column are assigned colors by cycling through `color_discrete_sequence`
        in the order described in `category_orders`, unless the value of
        `color` is a key in `color_discrete_map`. Various useful color
        sequences are available in the `plotly.express.colors` submodules,
        specifically `plotly.express.colors.qualitative`.
    color_discrete_map: dict with str keys and str values (default `{}`)
        String values should define valid CSS-colors Used to override
        `color_discrete_sequence` to assign a specific colors to marks
        corresponding with specific values. Keys in `color_discrete_map` should
        be values in the column denoted by `color`. Alternatively, if the
        values of `color` are valid colors, the string `'identity'` may be
        passed to cause them to be used directly.
    color_continuous_scale: list of str
        Strings should define valid CSS-colors This list is used to build a
        continuous color scale when the column denoted by `color` contains
        numeric data. Various useful color scales are available in the
        `plotly.express.colors` submodules, specifically
        `plotly.express.colors.sequential`, `plotly.express.colors.diverging`
        and `plotly.express.colors.cyclical`.
    range_color: list of two numbers
        If provided, overrides auto-scaling on the continuous color scale.
    color_continuous_midpoint: number (default `None`)
        If set, computes the bounds of the continuous color scale to have the
        desired midpoint. Setting this value is recommended when using
        `plotly.express.colors.diverging` color scales as the inputs to
        `color_continuous_scale`.
    projection: str 
        One of `'equirectangular'`, `'mercator'`, `'orthographic'`, `'natural
        earth'`, `'kavrayskiy7'`, `'miller'`, `'robinson'`, `'eckert4'`,
        `'azimuthal equal area'`, `'azimuthal equidistant'`, `'conic equal
        area'`, `'conic conformal'`, `'conic equidistant'`, `'gnomonic'`,
        `'stereographic'`, `'mollweide'`, `'hammer'`, `'transverse mercator'`,
        `'albers usa'`, `'winkel tripel'`, `'aitoff'`, or `'sinusoidal'`Default
        depends on `scope`.
    scope: str (default `'world'`).
        One of `'world'`, `'usa'`, `'europe'`, `'asia'`, `'africa'`, `'north
        america'`, or `'south america'`Default is `'world'` unless `projection`
        is set to `'albers usa'`, which forces `'usa'`.
    center: dict
        Dict keys are `'lat'` and `'lon'` Sets the center point of the map.
    fitbounds: str (default `False`).
        One of `False`, `locations` or `geojson`.
    basemap_visible: bool
        Force the basemap visibility.
    title: str
        The figure title.
    template: str or dict or plotly.graph_objects.layout.Template instance
        The figure template name (must be a key in plotly.io.templates) or
        definition.
    width: int (default `None`)
        The figure width in pixels.
    height: int (default `None`)
        The figure height in pixels.
    
    Returns
    -------
        plotly.graph_objects.Figure

None
In [3]:
import plotly.io as pio
pio.templates
Out[3]:
Templates configuration
-----------------------
    Default template: 'plotly'
    Available templates:
        ['ggplot2', 'seaborn', 'simple_white', 'plotly',
         'plotly_white', 'plotly_dark', 'presentation', 'xgridoff',
         'ygridoff', 'gridon', 'none']
In [4]:
print(help(fig.update_layout))
Help on method update_layout in module plotly.basedatatypes:

update_layout(dict1=None, overwrite=False, **kwargs) method of plotly.graph_objs._figure.Figure instance
    Update the properties of the figure's layout with a dict and/or with
    keyword arguments.
    
    This recursively updates the structure of the original
    layout with the values in the input dict / keyword arguments.
    
    Parameters
    ----------
    dict1 : dict
        Dictionary of properties to be updated
    overwrite: bool
        If True, overwrite existing properties. If False, apply updates
        to existing properties recursively, preserving existing
        properties that are not specified in the update operation.
    kwargs :
        Keyword/value pair of properties to be updated
    
    Returns
    -------
    BaseFigure
        The Figure object that the update_layout method was called on

None
In [ ]: